<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  
</head>
<body style="height: 3000px;">
  <div id="app">
    <common-head ref="head"></common-head>
  </div>
  <script src="./vue.js"></script>
  <script>
    // 全局组件
    const CommonHead =  {
      template: `
        <div> 
          <h1 ref="title">我是一个公共头部组件</h1>
          <button ref="btn">按钮</button> 
          <input ref="input" v-model="msg"/>
        </div>
      `,
      data(){
        return {
          msg:"",
          aa: '我是组件数据'
        }
      },
      mounted(){
        console.log(this.$refs)
        this.$refs.btn.style.background="red";
      }
    }
    Vue.component('CommonHead', CommonHead)
    const vm = new Vue({
      el: '#app',
      mounted() {
        console.log(this.$refs.head);

      },
    })
  </script>
</body>
</html>